package com.lovo;

import javax.swing.*;
import java.awt.*;

public class Test02 extends JFrame {
    private LoginPanel loginPanel = new LoginPanel(this);
    private MenuPanel menuPanel = new MenuPanel(this);
    private Image bgImg = Util.getImage("/images/timg.jpg");


    private CardLayout cardLayout = new CardLayout();
    public Test02(){
        this.setContentPane(new JPanel(){
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgImg,0,0,800,600,this);
            }
        });
        this.setLayout(cardLayout);
        this.add("login",loginPanel);
        this.add("menu",menuPanel);
        this.setSize(800,600);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible(true);
    }
    public void switchPanel(String name){
        cardLayout.show(this.getContentPane(),name);
    }

    public static void main(String[] args) {
        new Test02();
    }
}
